<template>
  <div>
    <component :is="currentComponent"></component>
    <button @click="loadComponent('my-component')">加载组件</button>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      currentComponent: null
    };
  },
  methods: {
    loadComponent(componentName) {
      // 使用webpack动态import语法加载组件
      import(`@/components/${componentName}.vue`).then((component) => {
        this.currentComponent = component.default;
      });
    }
  }
};
</script>